using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using System.IO.Ports;
using System.Text;

#if MINI
using SecretLabs.NETMF.Hardware.NetduinoMini;
#else
using SecretLabs.NETMF.Hardware.Netduino;
#endif

namespace codebase
{
    public class windowMain : UI.Window
    {
        UI.Image logo;
        UI.Frame menuFrame;

        UI.Button menuTerminal;
        UI.Button menuSettings;

        SerialMonitor mon;

        public windowMain(UI.WindowManager manager, SerialMonitor monitor)
        {
            Initialize(manager, monitor);
        }

        public void Initialize(UI.WindowManager manager, SerialMonitor monitor)
        {
            base.Initialize(manager, 0, 0);

            mon = monitor;

            FullScreen = true;
            Text = "Serial / IO Monitor - SF.net 2013";
            Gradient = true;
            Effect = true;
            EffectMode = EffectType.Circles;

            logo = (UI.Image)Add(UI.Window.ControlTypes.Image, 16, 26);

            menuFrame = (UI.Frame)Add(UI.Window.ControlTypes.Frame, 1, 2);
            menuFrame.Width = cX(16);
            menuFrame.Height = cY(8);
            menuFrame.Text = "Main Menu";

            menuTerminal = (UI.Button)Add(UI.Window.ControlTypes.Button, 1, 3);
            menuTerminal.Text = "Terminal";
            menuTerminal.Released += new UI.Button.ButtonReleasedDelegate(menuTerminal_Released);

            menuSettings = (UI.Button)Add(UI.Window.ControlTypes.Button, 1, 6);
            menuSettings.Text = "Settings";
            menuSettings.Released += new UI.Button.ButtonReleasedDelegate(menuSettings_Pressed);
        }

        void menuTerminal_Released(UI.Button btn)
        {
            Visible = false;
            //windowTerminal term = new windowTerminal(Parent, mon);
            //term.Visible = true;

            Window0 win0 = new Window0(Parent);
            win0.Visible = true;

            Parent.Redraw();
        }

        void menuSettings_Pressed(UI.Button btn)
        {
            Visible = false;

            windowSettings settings = new windowSettings(Parent, mon);
            settings.Visible = true;

            Parent.Redraw();
        }
    }
}
